#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdlib.h>
int is_lily_number(int n) {
    int tmp = n;
    int count = n;
    int sum = 0;
    int div = 10;
    int rem;

    while (count) {
        tmp = n;
        rem = tmp % div;
        tmp /= div;
        sum += rem * tmp;
        div = div * 10;
        count /= 10;
    }
    if (sum == n)
        return 1;
    return 0;
}
int main() {
    int ret;
    for (int i = 1000; i < 10000; i++) {
        ret = is_lily_number(i);
        if (ret) {
            printf("%d ", i);
        }
    }
    system("pause");
    return 0;

}